﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using syc.Dal.Sale;
using System.Data;
using System.Data.SqlClient;
using System.Configuration;
namespace syc.Sale
{
    public partial class 产品加工合同 : System.Web.UI.Page
    {
        protected string 供货单位;
        protected string 地址;
        protected string 电话;
        protected string 开户银行;
        protected string 帐号;
        protected string 邮政编码;
        protected string 税号;
        protected int m1 = 1;
        protected int m2 = 2;
        protected int m3 = 3;

        protected string id = "";
        protected int[] id_length = new int[6];

        protected string[] 产品 = new string[6];
        protected string[] 规格 = new string[6];
        protected string[] 单位 = new string[6];
        protected string[] 数量 = new string[6];
        protected string[] 单价 = new string[6];
        protected string[] 金额 = new string[6];
        protected string[] 金额大写 = new string[6];

        protected string 中标产品 = "";
        protected string 技术规范 = "";
        protected int k = 0;
        protected void Page_Load(object sender, EventArgs e)
        {

            if (!this.IsPostBack)
            {
                if (Request.QueryString["ID"] != null)
                {
                    id = Request.QueryString["ID"];
                }
                if (id != "")
                {
                    SqlConnection Conn = new SqlConnection();
                    Conn.ConnectionString = ConfigurationManager.ConnectionStrings["SCMConnectionString1"].ConnectionString;
                    Conn.Open();
                    SqlCommand Cmd = new SqlCommand();
                    Cmd.Connection = Conn;
                    Cmd.CommandText = "select ID from 采购材料合同 where 编号='" + id + "'";
                    SqlDataReader read = Cmd.ExecuteReader();
                    int i = 0;
                    while (read.Read())
                    {
                        id_length[i] = read.GetInt32(0);
                        i++;
                    }
                    read.Close();
                    Cmd.Clone();
                    Conn.Close();
                    for (int j = 0; j < id_length.Length; j++)
                    {
                        if (id_length[j] != 0)
                        {
                            this.SqlDataSource1.SelectParameters["ID"].DefaultValue = id_length[j].ToString();
                            this.SqlDataSource1.Select(DataSourceSelectArguments.Empty);
                        }
                    }

                }
            }
        }

        protected void SqlDataSource1_Selected(object sender, SqlDataSourceStatusEventArgs e)
        {

            if (!Convert.IsDBNull(e.Command.Parameters[3].Value))
            {

                this.BianHao.Text = (string)e.Command.Parameters[1].Value;


                //this.NianDu.Text = ((int)e.Command.Parameters[5].Value).ToString();
                //byte jidu=(byte)e.Command.Parameters[6].Value;
                //this.JiDu.Text = jidu.ToString();
                //if (jidu == 2)
                //{
                //    m1 = 4;
                //    m2 = 5; 
                //    m3 = 6;
                //}
                //else if (jidu ==3)
                //{
                //    m1 = 7;
                //    m2 = 8;
                //    m3 = 9;
                //}
                //else if (jidu == 4)
                //{
                //    m1 = 10;
                //    m2 = 11;
                //    m3 = 12;
                //}
                数量[k] = ((double)e.Command.Parameters[7].Value).ToString();
                单价[k] = ((double)e.Command.Parameters[8].Value).ToString();
                decimal jine = Convert.ToDecimal((double)e.Command.Parameters[7].Value * (double)e.Command.Parameters[8].Value);
                金额[k] = jine.ToString();
                金额大写[k] = new syc.Dal.Sale.DecimalToUpper().ToUpper(jine);

                //this.ShuLiang.Text = ((double)e.Command.Parameters[7].Value).ToString();
                //this.DanJia.Text = ((double)e.Command.Parameters[8].Value).ToString();
                //decimal jine = Convert.ToDecimal( (double)e.Command.Parameters[7].Value * (double)e.Command.Parameters[8].Value);
                //this.JinE.Text = jine.ToString();
                //this.JinEDaXie.Text = new syc.Dal.Sale.DecimalToUpper().ToUpper(jine);
                //  this.ChangDu.Text = ((double)e.Command.Parameters[9].Value).ToString();

                //this.Date1.Text = ((DateTime)e.Command.Parameters[10].Value).ToLongDateString();
                // this.Date1.Text = "";
                //    this.Date2.Text = ((DateTime)e.Command.Parameters[11].Value).ToLongDateString();
                //this.YunShu.Text = (string)e.Command.Parameters[12].Value;
                //this.BeiZhu.Text = (string)e.Command.Parameters[13].Value;
                //   this.JiaoHuo.Text = ((double)e.Command.Parameters[14].Value).ToString();

                //this.JiaoHuo1.Text = ((double)e.Command.Parameters[15].Value).ToString();
                //this.JiaoHuo2.Text = ((double)e.Command.Parameters[16].Value).ToString();
                //this.JiaoHuo3.Text = ((double)e.Command.Parameters[17].Value).ToString();
                //this.JiaoHuo4.Text = ((double)e.Command.Parameters[18].Value).ToString();
                //this.JiaoHuo5.Text = ((double)e.Command.Parameters[19].Value).ToString();
                //this.JiaoHuo6.Text = ((double)e.Command.Parameters[20].Value).ToString();
                //this.JiaoHuo7.Text = ((double)e.Command.Parameters[21].Value).ToString();
                //this.JiaoHuo8.Text = ((double)e.Command.Parameters[22].Value).ToString();
                //this.JiaoHuo9.Text = ((double)e.Command.Parameters[23].Value).ToString();
                产品[k] = (string)e.Command.Parameters[24].Value;
                //this.LeiBie2.Text = (string)e.Command.Parameters[24].Value;
                规格[k] = (string)e.Command.Parameters[25].Value;
                //if (!Convert.IsDBNull(e.Command.Parameters[25].Value))
                //{
                //    this.GuiGe.Text = (string)e.Command.Parameters[25].Value;
                //}
                //else
                //{
                //    this.GuiGe.Text = "";
                //}
                this.GongHuo.Text = (string)e.Command.Parameters[26].Value;
                单位[k] = (string)e.Command.Parameters[27].Value;
                //this.DanWei.Text = (string)e.Command.Parameters[27].Value;
                Supplier supplier = new Supplier();
                supplier = supplier.getSupplier((int)e.Command.Parameters[4].Value, 1);
                供货单位 = supplier.get详细供货单位();
                地址 = supplier.get地址();
                电话 = supplier.get电话();
                开户银行 = supplier.get开户银行();
                帐号 = supplier.get账号();
                邮政编码 = supplier.get邮政编码();
                税号 = supplier.get税号();
                this.Supplier.Text = 供货单位;
                this.Address.Text = 地址;
                this.Tele.Text = 电话;
                this.Bank.Text = 开户银行;
                this.Num.Text = 帐号;
                this.Zip.Text = 邮政编码;
                this.Tax.Text = 税号;
                k++;
            }
        }
    }
}
